/**
 * 
 */
package ch.gje.playios.server.handler;

import java.io.IOException;

import ch.gje.playios.server.HTTPConnection;

/**
 * Sends 500 Internal Server Error
 * 
 * @author jannis <jannis@gje.ch>
 */
public class InternalServerErrorHandler extends RequestHandler {

    /**
     * Constructor
     *
     * @param connection
     *            the HTTP connection
     */
    public InternalServerErrorHandler(HTTPConnection connection) {
        super(connection);
        try {
            handleQuery(); // bypass RequestHandler's handle()
        } catch (IOException e) {
            /* no good */
            e.printStackTrace();
        }
    }

    /*
     * (non-Javadoc)
     *
     * @see server.QueryHandler#handleQuery(java.lang.String)
     */
    @Override
    public void handleQuery() throws IOException {
        setResponseStatus(500, "Internal Server Error");
        sendHeaders();
        connection.send("500 Internal Server Error");
        connection.close();
    }
}
